<?php
/**
 * 删除重复的数据
 * @author wangtao
 * @version 2010.03.13
 */
set_time_limit(0);
define('IN_WT', true);
include 'include.php';
include 'config.php';
set_time_limit(0);

#$link = mysqlDB::con();

$link = mysql_connect(DBHOST, DBUSER, DBPASSW);
mysql_select_db(DBNAME, $link);



for (;;)
{
	//sleep(1);
	$sql = 'ALTER TABLE `post_into` ADD UNIQUE (`Post_Link`)';
	$d = mysql_query($sql, $link) or $e = mysql_error($link);
	$e = explode('\'', $e);
	if ($d)
	{
		d('ok');
		system('shutdown -s');
	}
	else
	{
		d($e[1]);
		//sleep(1);
		if(strlen($e[1]) >= 64)
		{
			$sql2 = 'DELETE FROM `feed`.`post_into` 
		WHERE `post_into`.`Post_Link` LIKE \'' . $e[1] . '%\' LIMIT 1';
			mysql_query($sql2);
		}
		$sql2 = 'DELETE FROM `feed`.`post_into` 
		WHERE `post_into`.`Post_Link` = \'' . $e[1] . '\' LIMIT 1';
		mysql_query($sql2);
	}
}

function d($data, $functionName = '')
{
	$fp = fopen('C:/Users/wangtao/Desktop/feed.txt','a');
	fwrite($fp, $data . '         ' . date('Y-m-d H:i:s') . "\n");
	fclose($fp); //test
}